//
//  HMHomeTitleView.swift
//  iOSWeibo12
//
//  Created by Admin on 16/9/12.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class HMHomeTitleView: UIButton {
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // 自定义构造函数创建按钮
    init(title: String) {
        super.init(frame: CGRect())
        
        setTitle(title, for: UIControlState.normal)
        setImage(UIImage(named: "navigationbar_arrow_down"), for: UIControlState.normal)
        setTitleColor(UIColor.black, for: UIControlState.normal)
        
        sizeToFit()
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        
        // 把label移动到左边
        titleLabel?.frame.origin.x = 0
        
        // 把图片移到label的后面
        imageView?.frame.origin.x = titleLabel!.frame.width + 3
    }
}
